Skip to content

fix: downloads count for ai report (IN-1182) - #4228

Merged
joanagmaia merged 11 commits into
mainfrom
fix/IN-1182-downloads-count-ai-report
Jun 19, 2026
Merged

fix: downloads count for ai report (IN-1182)#4228
joanagmaia merged 11 commits into
mainfrom
fix/IN-1182-downloads-count-ai-report

Conversation

@joanagmaia

@joanagmaia joanagmaia commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Fixes incorrect download and Docker pull metrics on the Agentic AI projects list by rewriting the ai_package_metrics node in agentic_ai_projects_list_copy.pipe.

What changed:

  • ai_repos now excludes repositories with an empty insightsProjectId, so all downstream nodes (activity, contributor, PR, issue metrics) automatically skip those repos.
  • ai_package_metrics is restructured as a three-level pipeline:
    1. Inner deduplicationargMax(..., updatedAt) per (insightsProjectId, date, ecosystem, repo, name) to collapse duplicate/versioned rows in packageDownloads.
    2. Per-package rollup — groups by (insightsProjectId, ecosystem, repo, name) and applies argMax(..., date) / argMaxIf(..., date, ...) independently per package, so each package contributes its own latest cumulative value and its own 30-day delta regardless of when it was last updated.
    3. Project rollupsum across packages per insightsProjectId for downloads and Docker pulls; max for dependent repo/package counts.

The previous single-pass query either picked one package's value per project (original) or summed per calendar date and silently dropped packages whose last row predated the project's latest date (intermediate version).


Note

Medium Risk
Changes analytics aggregation for a production report datasource; logic is more correct but totals and 30d deltas may shift materially for multi-package projects.

Overview
Fixes inflated or incomplete download, Docker pull, and related package metrics on the Agentic AI projects list by changing the daily copy pipe that feeds agentic_ai_projects_list_ds.

ai_repos now requires a non-empty insightsProjectId, so repos without a linked insights project are dropped from every downstream metric node.

ai_package_metrics is rebuilt as a three-stage rollup over packageDownloads: dedupe rows per package/day with argMax(..., updatedAt), compute each package’s latest totals and 30-day deltas, then sum downloads/Docker metrics (and max for dependent counts) per insightsProjectId. That replaces a single-pass argMax/FINAL query that could reflect only one package or miss packages whose last snapshot was older than the project’s latest date.

Reviewed by Cursor Bugbot for commit fa1083b. Bugbot is set up for automated code reviews on this repo. Configure here.

Signed-off-by: Joana Maia <jmaia@contractor.linuxfoundation.org>
Copilot AI review requested due to automatic review settings June 17, 2026 11:07
Comment thread services/libs/tinybird/pipes/agentic_ai_projects_list_copy.pipe Outdated
Signed-off-by: Joana Maia <jmaia@contractor.linuxfoundation.org>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the Tinybird pipe that computes per-project package metrics for the Agentic AI report, aiming to correct how cumulative package download metrics are deduplicated and rolled up to the project level.

Changes:

  • Replaces argMax(..., date) reads from packageDownloads FINAL with a deduplication subquery using argMax(..., updatedAt) per (insightsProjectId, date, ecosystem, repo, name).
  • Switches the rollup logic for downloads and docker pulls to use max / maxIf when computing totals and 30-day deltas.
  • Tightens the AI project filter to exclude empty insightsProjectId values from ai_repos.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread services/libs/tinybird/pipes/agentic_ai_projects_list_copy.pipe Outdated
Comment thread services/libs/tinybird/pipes/agentic_ai_projects_list_copy.pipe Outdated
Comment thread services/libs/tinybird/pipes/agentic_ai_projects_list_copy.pipe Outdated
Signed-off-by: Joana Maia <jmaia@contractor.linuxfoundation.org>
Copilot AI review requested due to automatic review settings June 17, 2026 11:20

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.

Comment thread services/libs/tinybird/pipes/agentic_ai_projects_list_copy.pipe Outdated
Signed-off-by: Joana Maia <jmaia@contractor.linuxfoundation.org>
Signed-off-by: Joana Maia <jmaia@contractor.linuxfoundation.org>
Signed-off-by: Joana Maia <jmaia@contractor.linuxfoundation.org>
Copilot AI review requested due to automatic review settings June 17, 2026 11:27

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 80d2424. Configure here.

Comment thread services/libs/tinybird/pipes/agentic_ai_projects_list_copy.pipe

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

Copilot AI review requested due to automatic review settings June 17, 2026 13:07

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.

Comment thread services/libs/tinybird/pipes/agentic_ai_projects_list_copy.pipe
@joanagmaia
joanagmaia requested a review from gaspergrom June 17, 2026 13:45
@gaspergrom

Copy link
Copy Markdown
Contributor

lgtm

Copilot AI review requested due to automatic review settings June 19, 2026 11:24

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

@joanagmaia
joanagmaia merged commit b1795fa into main Jun 19, 2026
17 checks passed
@joanagmaia
joanagmaia deleted the fix/IN-1182-downloads-count-ai-report branch June 19, 2026 11:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants